﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using VipCo.Entities;
using VipCo.Data;

public partial class Controls_ChuyenMucControl : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            HienThiNhomDiaDiem();
        }
    }

    private void HienThiNhomDiaDiem()
    {
        int TotalRows = 0;
        TList<NhomChuyenMuc> TList_TinTuc = DataRepository.NhomChuyenMucProvider.GetPaged("TrangThai = 1", "ID ASC", 0, 0, out TotalRows);
        dlChuyenmuc.DataSource = TList_TinTuc;
        dlChuyenmuc.DataBind();
    }

    /// <summary>
    /// Handles ItemDataBound, Binds ExchangesTo to the Child DataList
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void dlFromTrades_ItemDataBound(object sender, DataListItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {

            DataListItem parentList = e.Item;
            Literal lit_Name = (Literal)parentList.FindControl("lit_Id");
            string i = (lit_Name.Text).ToString();
            int j = Convert.ToInt32(i);
            int TotalRows = 0;
            TList<DiaDiem> TList_DiaDiems = DataRepository.DiaDiemProvider.GetPaged("IdChuyenMuc = " + j, "NgayCapNhat DESC", 0, 8, out TotalRows);
            // Retrieve the Parent List


            // Find the To Trades DataList Control
            DataList dlToTrades = (DataList)parentList.FindControl("dlChuyenmuctt");

            // Bind the ExchangeTo DataList
            dlToTrades.DataSource = TList_DiaDiems;
            dlToTrades.DataBind();
        }
    }

    public string GetSo(object Char)
    {
        string s = Char.ToString();
        int TotalRows = 0;
        TList<DiaDiem> TList_TinTuc = DataRepository.DiaDiemProvider.GetPaged("IdChuyenMuc = " + s, "Id ASC", 0, 0, out TotalRows);

        return TotalRows.ToString();
    }
}